<?php
/*
 * @Author: wanzhengxin
 * @Date: 2021-04-01 21:58:34
 */


namespace app\user\model;


use app\index\model\Base;//default 不变，不要改

class User extends Base
{
    protected $pk ='u_id';
    public function reg($map,$data)
    {
        $user =$this->get($map);
        if( $user==null){
            $this->saveModel($data);
            return 1;
        }else{
            $a=['status'=>0,"msg"=>"已经存在数据"];
            return json_encode($a);
        }
    }

    public function doctor()
    {
        return $this->hasOne('app\doctor\model\Doctor','u_id','u_id');
    }
    public function userAddress()
    {
        return $this->hasMany('UserAddress','u_id','u_id');
    }
    public function appraise()
    {
        return $this->hasMany('Appraise','a_id','u_id');
    }
    public function getphotoAttr($img)
    {
        $host_public=config('host_public');

        if(preg_match("/https/i",$img)){
            return $img;
        }else{
            return $host_public.$img;
        };
    }
    // public function getemrcodeImgAttr($img)
    // {
    //     $host_public=config('host_public');
    //     return $host_public.$img;
    // }

}